

*------------------------------------------------------------------------------**------------------------------------------------------------------------------*
* import data scpc *
*------------------------------------------------------------------------------**------------------------------------------------------------------------------*

*------------------------------------------------------------------------------*
* 2015 *
*------------------------------------------------------------------------------*

use "data/source/scpc_2015.dta", replace
gen scpc_year = 2015
duplicates report prim_key // unique

rename 	pa120_a bitcoin_heardof	

rename 	pa131a bitcoin_familiar 		

rename 	pa121_a bitcoin_own				

rename 	pa122_a bitcoin_everown			

rename 	pa125 	bitcoin_reasonnotown		
rename 	pa126_a bitcoin_reasonown1st		
rename 	pa126_b bitcoin_reasonown2nd		
 
rename 	pa123_a_number	bitcoin_coins		
rename 	pa123_a_us 		bitcoin_dollar		

rename 	pa128_a	bitcoin_transaction			

rename 	pa130_a bitcoin_expectation_nextweek 
rename 	pa130_b bitcoin_expectation_nextmonth
rename 	pa130_c bitcoin_expectation_nextyear 

rename 	dateofbirth_year 	birthyear
rename 	de010				income_band		
rename 	de013				homeowner
rename 	de016				asset

keep 	prim_key scpc_year tsstart tsend /// identifiers and dates
		gender highesteducation  birthyear income_band homeowner asset /// stateborn statereside ethnicity demographics
		bitcoin* // othercrypto*	cryptodata

order 	prim_key scpc_year  tsstart tsend
sort 	prim_key scpc_year
save "data/working/scpc_2015_tmp.dta", replace 

 
*------------------------------------------------------------------------------*
* 2016 *
*------------------------------------------------------------------------------*

use "data/source/scpc_2016.dta", replace
gen scpc_year = 2016
duplicates report prim_key // unique

rename 	pa120_a bitcoin_heardof	

rename 	pa131a bitcoin_familiar 		

rename 	pa121_a bitcoin_own				

rename 	pa122_a bitcoin_everown			

rename 	pa125 	bitcoin_reasonnotown		
rename 	pa126_a bitcoin_reasonown1st		
rename 	pa126_b bitcoin_reasonown2nd		
 
rename 	pa123_a_number	bitcoin_coins		
rename 	pa123_a_us 		bitcoin_dollar		

rename 	pa128_a	bitcoin_transaction			

rename 	pa130_a bitcoin_expectation_nextweek 
rename 	pa130_b bitcoin_expectation_nextmonth
rename 	pa130_c bitcoin_expectation_nextyear 

rename 	dateofbirth_year 	birthyear
rename 	de010				income_band		
rename 	de013				homeowner
rename 	de016				asset

keep 	prim_key scpc_year tsstart tsend /// identifiers and dates
		gender highesteducation  birthyear income_band homeowner asset /// stateborn statereside ethnicity demographics
		bitcoin* // othercrypto*	cryptodata

order 	prim_key scpc_year  tsstart tsend
sort 	prim_key scpc_year
save "data/working/scpc_2016_tmp.dta", replace 
 
*------------------------------------------------------------------------------*
* 2017 *
*------------------------------------------------------------------------------*

use "data/source/scpc_2017.dta", replace
gen scpc_year = 2017
duplicates report prim_key // unique

rename 	pa120_a bitcoin_heardof	

rename 	pa131a1 bitcoin_familiar 		

rename 	pa121_a bitcoin_own				

rename 	pa122_a bitcoin_everown			
replace bitcoin_everown = 0 if bitcoin_everown == 2 // different codification from before		

rename 	pa125 	bitcoin_reasonnotown		
rename 	pa126_a bitcoin_reasonown1st		
rename 	pa126_b bitcoin_reasonown2nd		
 
rename 	pa123_a_number	bitcoin_coins		
rename 	pa123_a_us 		bitcoin_dollar		

rename 	pa128_a	bitcoin_transaction			
replace bitcoin_transaction = 0 if bitcoin_transaction == 2 // different codification from before


rename 	pa130_a bitcoin_expectation_nextweek 
rename 	pa130_b bitcoin_expectation_nextmonth
rename 	pa130_c bitcoin_expectation_nextyear 

rename 	dateofbirth_year 	birthyear
rename 	de010				income_band		
rename 	de013				homeowner
rename 	de016				asset

keep 	prim_key scpc_year tsstart tsend /// identifiers and dates
		gender highesteducation  birthyear income_band homeowner asset /// stateborn statereside ethnicity demographics
		bitcoin* // othercrypto*	cryptodata

order 	prim_key scpc_year  tsstart tsend
sort 	prim_key scpc_year
save "data/working/scpc_2017_tmp.dta", replace 
 
 
  
*------------------------------------------------------------------------------*
* 2018 *
*------------------------------------------------------------------------------*

use "data/source/scpc_2018.dta", replace
gen scpc_year = 2018
duplicates report uasid // unique
rename uasid prim_key 	// change in identifier here

rename 	pa120_a bitcoin_heardof	
replace bitcoin_heardof = 0 if bitcoin_heardof == 2 // different codification from before

rename 	pa131a1 bitcoin_familiar 		

rename 	pa121_a bitcoin_own	
replace bitcoin_own = 0 if bitcoin_own == 2 // different codification from before
		
rename 	pa122_a bitcoin_everown	
replace bitcoin_everown = 0 if bitcoin_everown == 2 // different codification from before		


*rename 	pa125 	bitcoin_reasonnotown		
rename 	pa126_a bitcoin_reasonown1st		
rename 	pa126_b bitcoin_reasonown2nd		
 
rename 	pa123_a_number	bitcoin_coins		
rename 	pa123_a_us 		bitcoin_dollar		

rename 	pa128_a	bitcoin_transaction			
replace bitcoin_transaction = 0 if bitcoin_transaction == 2 // different codification from before


rename 	pa130_a bitcoin_expectation_nextweek 
rename 	pa130_b bitcoin_expectation_nextmonth
rename 	pa130_c bitcoin_expectation_nextyear 

rename 	dateofbirth_year 	birthyear
*rename 	de010				income_band		
rename 	hhincome			income_band	 // different codification from before			
rename 	de013				homeowner
rename 	de016				asset

replace gender = 2 if gender==0 // different codification from before		

keep 	prim_key scpc_year tsstart tsend /// identifiers and dates
		gender highesteducation  birthyear income_band homeowner asset /// stateborn statereside ethnicity demographics
		bitcoin* // othercrypto*	cryptodata

order 	prim_key scpc_year  tsstart tsend
sort 	prim_key scpc_year
save "data/working/scpc_2018_tmp.dta", replace 
 
 
*------------------------------------------------------------------------------**------------------------------------------------------------------------------*
* Append all and save *
*------------------------------------------------------------------------------**------------------------------------------------------------------------------*

use "data/working/scpc_2015_tmp.dta", clear
append using "data/working/scpc_2016_tmp.dta"
append using "data/working/scpc_2017_tmp.dta"
append using "data/working/scpc_2018_tmp.dta"

duplicates report prim_key
duplicates report prim_key scpc_year // unique

order prim_key scpc_year 
sort prim_key scpc_year 


/*
The variable prim key is a 9 digit character variable of the form yymmxxxxx, where yy is the
two-digit year (16 for 2016, 17 for 2017, etc.) in which the respondent joined the UAS panel,
mm is the month the respondent joined the UAS panel (01 for January, 02 for February, etc.),
and xxxxx is a random five digit number. The prim key for a UAS member is the same
across all UAS surveys. This allows data users to merge other UAS survey datasets onto the
SCPC dataset.
*/


save "data/working/data_scpc.dta", replace 

 


